<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <p>
           品牌：<input v-model="userInfo.brand" type="text">
        </p>
        <p>
            系列：<input v-model="userInfo.series" type="text">
        </p>
        <p>
            型号：<input v-model="userInfo.creation" type="text">
        </p>
        <!-- <ul>
            <li v-for="item in 20">
                {{ item }}
            </li>
        </ul> -->
        <!-- <input v-model="brand + series + creation" type="text"> -->

        <h2>
            {{ userInfo.brand + userInfo.series + userInfo.creation }}
        </h2>

       

        <!-- 计算属性 -- computed -->
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        new Vue({
            el: "#app",
            data: {
                val: "",
                userInfo: [
                        {
                            brand: "奥迪",
                            series: "奥迪A4",
                            creation: "2021"
                        },
                        {
                            brand: "奥迪",
                            series: "奥迪A6",
                            creation: "2021"
                        },
                        {
                            brand: "奥迪",
                            series: "奥迪A6",
                            creation: "2020"
                        },
                        {
                            brand: "奥迪",
                            series: "奥迪A8",
                            creation: "2020"
                        },
              ],
              changeLeft() {
                    this.count--
                    if (this.count === (-1)) {
                        this.count = 3
                    }

                },
            },
            // 计算属性  只要依赖的值不发生改变，会直接读取上一次的缓存结果
            // 
            // computed: {
            //     newTitle() {
            //         return this.userInfo.brand + this.userInfo.series + this.userInfo.creation 
            //     }  
            // },
            // 深度监听   监听的类型为引用类型
            watch: {
               
                

                // 深度监听
                userInfo: {
                    // 开启深度监听 
                    deep: true,
                    handler(newValue, oldValue) {
                        this.userInfo.brand=newValue.brand
                    }
                }
            }
        })
        // 作业
        // 1. 
        // [
        //     {
        //         brand: "奥迪",
        //         series: "奥迪A4",
        //         creation: "2021"
        //     },
        //     {
        //         brand: "奥迪",
        //         series: "奥迪A6",
        //         creation: "2021"
        //     },
        //     {
        //         brand: "奥迪",
        //         series: "奥迪A6",
        //         creation: "2020"
        //     },
        //     {
        //         brand: "奥迪",
        //         series: "奥迪A8",
        //         creation: "2020"
        //     },
        // ]
    </script>
</body>
</html>